const signatureObj = {
    words: [
        -1974056523, -2090763459, -274777964, -175812545,
        -286718405, 1074692717, -1942938812, 1915841967,
        557835171, -562632921, -1702824853, 1450899999,
        1275309881, -1897301273, -1593864880, 1107606055
    ],
    sigBytes: 64
};

// 将 32 位有符号整数转为无符号字节并拼接为 16 进制
function wordsToHex(words, sigBytes) {
    const hex = [];
    for (let i = 0; i < sigBytes / 4; i++) {
        const word = words[i];
        // 处理负数：转换为无符号 32 位整数
        const unsignedWord = word >>> 0;
        // 按大端序（big-endian）转换为 8 位 16 进制
        hex.push(
            ((unsignedWord >> 24) & 0xff).toString(16).padStart(2, '0'),
            ((unsignedWord >> 16) & 0xff).toString(16).padStart(2, '0'),
            ((unsignedWord >> 8)  & 0xff).toString(16).padStart(2, '0'),
            (unsignedWord & 0xff).toString(16).padStart(2, '0')
        );
    }
    return hex.join('').slice(0, sigBytes * 2); // 限制长度为 sigBytes
}

const hexSignature = wordsToHex(signatureObj.words, signatureObj.sigBytes);
console.log("16 进制签名:", hexSignature);